#ifndef HTTPSERVER_H
#define HTTPSERVER_H

#include<QObject>
#include<QtHttpServer/QHttpServer>
#include<QProtobufSerializer>
#include<QHostAddress>

#include"debug.h"


class HttpServer : public QObject
{
    Q_OBJECT
private:
    QHttpServer httpServer;

    //序列器
    QProtobufSerializer serializer;

    static HttpServer* instance;

    HttpServer(){}

public:

    static HttpServer* getInstance();

    //初始化
    bool init();

    //获取个人信息
    QHttpServerResponse getUserInfo(const QHttpServerRequest& req);

    //获取好友列表
    QHttpServerResponse getFriendList(const QHttpServerRequest& req);

    //获取会话列表
    QHttpServerResponse getSessionList(const QHttpServerRequest& req);

    //获取好友申请列表
    QHttpServerResponse getApplyList(const QHttpServerRequest& req);

    //获取最近消息
    QHttpServerResponse getRecentMessages(const QHttpServerRequest& req);

    //发送消息
    QHttpServerResponse sendMessage(const QHttpServerRequest& req);

    //修改名字
    QHttpServerResponse setNickName(const QHttpServerRequest& req);

    //修改标签
    QHttpServerResponse setDescription(const QHttpServerRequest& req);

    //获取手机验证码
    QHttpServerResponse getVerifyCode(const QHttpServerRequest& req);

    //修改手机号码
    QHttpServerResponse setPhone(const QHttpServerRequest& req);

    //修改头像
    QHttpServerResponse setAvatar(const QHttpServerRequest& req);

    //删除好友
    QHttpServerResponse removeFriend(const QHttpServerRequest& req);

    //好友申请
    QHttpServerResponse addFriendApply(const QHttpServerRequest& req);

    //同意好友申请
    QHttpServerResponse addAndRejectFriendProcess(const QHttpServerRequest& req);

    //创建会话
    QHttpServerResponse createChatSession(const QHttpServerRequest& req);

    //获取群聊会话成员信息
    QHttpServerResponse getChatSessionMember(const QHttpServerRequest& req);

    //搜索用户
    QHttpServerResponse searchFriend(const QHttpServerRequest& req);

    //通过关键字搜索历史消息
    QHttpServerResponse searchHistory(const QHttpServerRequest& req);

    //通过时间搜索历史消息
    QHttpServerResponse getHistory(const QHttpServerRequest& req);

    //用户名登录
    QHttpServerResponse userLogin(const QHttpServerRequest& req);
    //用户名注册
    QHttpServerResponse userRegister(const QHttpServerRequest& req);

    //通过手机号和手机验证码登录注册
    QHttpServerResponse phoneLogin(const QHttpServerRequest& req);
    QHttpServerResponse phoneRegister(const QHttpServerRequest& req);

signals:
};

#endif // HTTPSERVER_H
